home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000006_icon-group-sender _Wed Jul 2 09:27:28 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
1KB
Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Wed, 2 Jul 1997 12:29:46 MST
Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
id AA20607; Wed, 2 Jul 1997 12:29:46 -0700
Message-Id: <199707021627.JAA09747@orpheus.gemini.edu>
From: swampler@noao.edu (Steve Wampler)
Date: Wed, 2 Jul 1997 09:27:28 MST
X-Mailer: Mail User's Shell (7.2.3 5/22/91)
To: icon-group@cs.arizona.edu
Subject: A small puzzle
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Recently, the SNOBOL4 mailing list has been playing with ways (in
SNOBOL4/SPITBOL) of writing a procedure to return the longest
common prefix between strings. This is kinda a fun thing to
play with in Icon also, so I thought I'd invite people to post
their solutions to this problem.
Write a procedure lcp(s1,s2) that returns the longest common
prefix of strings s1 and s2. For example,
write(lcp("fool","foodchain"))
would output "foo", while
write(lcp("aardvark","elephant"))
would output "" (i.e. th
null string).
I have two basic solutions I like, one using string scanning (my
favorite) and one without string scanning. I also have a couple
derivatives that attempt to improve performance through heuristics.
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
O Sibile, si ergo, fortibus es inero.
Nobile, demis trux. Demis phulla causan dux.